package vtc;

import java.util.*;

public class DataEventIB
{
	private double bid_;
	private double ask_;
	private double last_;
	private double high_;
	private double low_;
	private double close_;
	private long volume_;
	private long bidSize_;
	private long askSize_;
	private long lastSize_;
	private Date timeStamp_;
		
	DataEventIB()
	{
		;
	}
	
	void setTickPrice(int field, double value)
	{
		switch (field) 
		{
	      case 1:
	           bid_ = value;
	           break;
	      case 2:
	           ask_ = value;
	           break;
	      case 4:
	           last_ = value;
	           break;
	      case 6:
	           high_ = value;
	           break;
	      case 7:
	           low_ = value;
	           break;
	      case 9:
	           close_ = value;
	           break;
	      default:
	           System.out.println("error: Not matched fieldId in setTickPrice()" );
	      		break;
		}

	}
	
	double getTickPrice(int field)
	{
		double value = 0;
		switch (field) 
		{
	      case 1:
	           value = bid_;
	           break;
	      case 2:
	           value = ask_;
	           break;
	      case 4:
	           value = last_;
	           break;
	      case 6:
	           value = high_;
	           break;
	      case 7:
	           value =low_;
	           break;
	      case 9:
	           value = close_;
	           break;
	      default:
	           System.out.println("error: Not matched fieldId in getTickPrice()" );
	      		break;
		}
		return value;
	}
	
	void setTickSize(int field, long value)
	{
		switch (field) 
		{
	      case 0:
	           bidSize_ = value;
	           break;
	      case 3:
	           askSize_ = value;
	           break;
	      case 5:
	           lastSize_ = value;
	           break;
	      case 8:
	           volume_ = value;
	           break;
	      default:
	           System.out.println("error: Not matched fieldId in setTickSize()" );
	      		break;
		}
	}
	
	long getTickSize(int field)
	{
		long value = 0;
		switch (field) 
		{
	      case 0:
	           value = bidSize_;
	           break;
	      case 3:
	           value = askSize_;
	           break;
	      case 5:
	           value = lastSize_;
	           break;
	      case 8:
	           value = volume_;
	           break;
	      default:
	           System.out.println("error: Not matched fieldId in getTickSize()" );
	      		break;
		}
		
		return value;
	}
	
	void setTickString(int tickType, String value)
	{
		switch (tickType) 
		{
	      case 45:
	           timeStamp_ = new Date(Long.valueOf(value).longValue()*1000);
	           break;
	      default:
	           System.out.println("error: Not matched fieldId in setTickString()" );
	      		break;
		}
	}
	
	Date timeStamp()
	{
		return timeStamp_;
	}
	
	public String toString()
	{
		String event =  "bid: " + bid_ + " ask: " + ask_ + " last: " + last_ + " high: " + high_ + " low: " + low_ + " close: " + close_ + " volume: " + volume_ + " bidSize: " + bidSize_ + " askSize: " + askSize_ + " lastSize: " + lastSize_ + "lastTimeStamp: " + timeStamp_ + "\n";
		return event;
	}
}